package cn.com.twoke.application.game.mario.core.ecs.component;

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.util.function.Supplier;

// 碰撞组件 - 定义实体的碰撞体积
public class ColliderComponent implements Component {
    public enum Type {
        SOLID,      // 普通固体
        ONE_WAY,    // 单向平台
        TRIGGER     // 触发器
    }

    /**
     * 传送门UI调试
     */
    private static Boolean DEBUG = false;


    public static void enableDebug(){
        DEBUG = true;
    }

    public static Boolean isDebug(){
        return DEBUG;
    }

    public Supplier<Shape> shape;
    public Type type = Type.SOLID;
    public int hitBoxColor = 0xff0000;

    public ColliderComponent(Supplier<Shape> shape) {
        this.shape = shape;
    }

    public Shape getShape() {
        return shape.get();
    }

    public Shape getTransformedShape(float x, float y) {
        AffineTransform transform = new AffineTransform();
        transform.translate(x, y);
        return transform.createTransformedShape(shape.get());
    }

}